var nowDate = getDay(0);
var resdata;
var url;
var urll;
var trStr="";
var userId  = sessionStorage.getItem("userId");
var username = sessionStorage.getItem("name");
var BillNO = "";
//StoreNO店号  userId 操作人
$(document).ready(function(){
	window.addEventListener('pageshow', function(e) {
    if (e.persisted) {
        window.location.reload();
    }else{
	StoreName = decodeURI(decodeURI(StoreName))
	Statue = decodeURI(decodeURI(Statue))
	$('#nameh').append(StoreNO+"."+StoreName);
	$('#Statueh').append(Statue);
	$('#name').text(sessionStorage.getItem("name"));
	}
		});
});
function pdfinish(){

	 dd.device.notification.confirm({
    message: "确认完成吗",
    title: "提示",
    buttonLabels: ['是', '否'],
    onSuccess : function(result) {
        if(result.buttonIndex==0){
					$.ajax({
					url: "../../typd/pdfinish"
					,type:'post'
					,data:JSON.stringify({"PaperNO":PaperNO,"OperName":username,"Tag":2})
					,contentType: "application/json; charset=utf-8"
					,dataType:'json'
					,success: function(res){
						layer.msg('盘点完成',{time:1000},function(){
										dd.device.base.getPhoneInfo({
										    onSuccess : function(data) {//iPhone
						                    if(data.brand == iPhone){
												sessionStorage.setItem("Creload", true);
											}
										    },
										    onFail : function(err) {}
										});
										goback();
									});
					}
				});
		}
    },
    onFail : function(err) {}
});


}

function shopcode(){
	StoreName =encodeURI(encodeURI(StoreName));
	Statue =encodeURI(encodeURI(Statue));
	urll = "jh_mendianpandian?BillNO="+PaperNO+"&StoreNO="+StoreNO+"&StoreName="+StoreName+"&Statue="+Statue+"&nw=F";
    window.location.href = urll;
}
function pdsearch(){
	StoreName =encodeURI(encodeURI(StoreName));
	Statue =encodeURI(encodeURI(Statue));

	url = "jh_mendianpandian1?PaperNO="+PaperNO+"&StoreNO="+StoreNO+"&StoreName="+StoreName+"&Statue="+Statue;//此处拼接内容
  	 window.location.href = url;
}
function pdcancel(){
   dd.device.notification.confirm({
    message: "确认撤销吗",
    title: "提示",
    buttonLabels: ['是', '否'],
    onSuccess : function(result) {
		if(result.buttonIndex==0){
					$.ajax({
						url: "../../typd/pdcancel"
						,type:'post'
						,data:JSON.stringify({"PaperNO":PaperNO,"OperName":username,"Tag":1})
						,contentType: "application/json; charset=utf-8"
						,dataType:'json'
						,success: function(res){
							layer.msg('盘点撤销',{time:1000},function(){
								dd.device.base.getPhoneInfo({
							    onSuccess : function(data) {//iPhone
							    if(data.brand == iPhone){
									sessionStorage.setItem("Creload", true);
								}
							},
							onFail : function(err) {}
							});
							goback();
						});
					}
			    });
			
		}
    },
    onFail : function(err) {}
});


}
function goback(){
	history.go(-1);
}
